package test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import hisp.Message;

import org.junit.Test;


public class test {
	@Test
	public void testMessageSetIdentity() {
		Message message = new Message();
		message.setMessage("don't");
		message.setIdentity ("abc", "1234", "b", "bbb");
		assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><message type=\"don't\"><identity><id>abc</id><password>1234</password><salt>b</salt><xml>bbb</xml></identity></message>", message.toXml());
	}
	
	@Test
	public void testMessageGetIdentity() {
		Message message = new Message();
		message.setMessage("don't");
		message.setIdentity ("abc", "1234", "b", "bbb");
		assertEquals("abc" , message.getIdentityAttribute("id"));
		assertEquals("1234" , message.getIdentityAttribute("password"));
		assertEquals("b" , message.getIdentityAttribute("salt"));
		assertEquals("bbb" , message.getIdentityAttribute("xml"));
	}
	
	@Test
	public void testMessageInit() {
		Message message = new Message("<?xml version=\"1.0\" encoding=\"UTF-8\"?><message type=\"don't\"><identity><id>abc</id><password>1234</password><salt>b</salt><xml>bbb</xml></identity></message>");
		System.out.println("[" + message.toXml() + "]");				
	}

}
